<template>
  <div class="multiVModelWrap">
    <h3>在子组件上 v-model:参数名 的方式，双绑多个数据</h3>
    <p>父组件中的position: {{ position }} <button @click="fatherChangePosition">父组件改变position</button></p>
    <p>父组件中的month: {{ month }} <button @click="fatherChangeMonth">父组件改变month</button></p>
    <subComponent v-model:month="month" v-model:position="position"></subComponent>
  </div>
</template>

<script lang="ts">
import subComponent from "./components/subComponent.vue";
import { defineComponent } from "vue";
export default defineComponent({
  components: {
    subComponent,
  },
  props: {
    user: {
      type: String,
      required: true,
    },
  },
  emits: [],
  data() {
    return {
      position: "珠海",
      month: "5",
    };
  },
  methods: {
    fatherChangePosition() {
      this.position = "广州";
    },
    fatherChangeMonth() {
      this.month = "6";
    },
  },
});
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
